//
//  ExUIButton.m
//  WxIOSReader
//
//  Created by anzeinfo on 12-7-6.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "ExUIButton.h"

@implementation ExUIButton

@end



@implementation UIButton(BackgroundColorForState)

- (void)setBackgroundColor:(UIColor *)backgroundColor forState:(UIControlState)state {
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(1, 1), NO, 0);
    [backgroundColor setFill];
    CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, 1, 1));
    UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext();
    [self setBackgroundImage:backgroundImage forState:state];
    UIGraphicsEndImageContext();
}

- (void)setBackgroundColor:(UIColor *)backgroundColor forState:(UIControlState)state withImage:(UIImage*)image width:(NSInteger)width height:(NSInteger)height{
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(width, height), NO, 0);
    [backgroundColor setFill];
    CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, width, height));
    [image drawInRect:CGRectMake((width - image.size.width)/2, (height - image.size.height)/2, image.size.width, image.size.height)];
    UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext();
    [self setBackgroundImage:backgroundImage forState:state];
    UIGraphicsEndImageContext();
}



@end